﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Outlook = Microsoft.Office.Interop.Outlook;
using Microsoft.Office.Core;



namespace ContactsForm
{
    class OutlookConn
    {
        private DataGridView grd_jr_cont;
        Outlook.Inspector olinsp;
        Outlook.Explorer olexp;
        Outlook.MAPIFolder ns;
        Outlook.MAPIFolder fldr;
        Outlook.Items items;
        object contfrmname = new object();
        Outlook._ContactItem contfrm;

        public OutlookConn(DataGridView grd_jr_cont, DataSet contacts)
        {
            this.grd_jr_cont = grd_jr_cont;
            Outlook._Application ol = (Outlook._Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Outlook.Application");
            olinsp = ol.ActiveInspector();
            olexp = ol.ActiveExplorer();
            ns = ol.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);
            object strid = grd_jr_cont.Rows[0].Cells["str_id"].Value;
            DataRow sid = contacts.Tables["projects"].Rows.Find(strid);            
            string str = "" + sid["str_city"] + " " + sid["str_st"] +
                " " + sid["str_num"] + " - " + sid["str_seq"] + "";
            //olexp.SelectFolder(ns.Folders["0001 Store Contacts"].Folders[str]);
            fldr = ns.Folders["0001 Store Contacts"].Folders[str];
            items = fldr.Items;
            contfrmname = "IPM.Contact.ProjectContactsv1";
          
            contfrm = items.Add("ContactForm");
            
        }


        public void ConnectPublicFolder(DataGridView dgv)
        {
            
            
            
            
            
            

        }
    }
}
